/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-31
 * Time: 18:45
 */

/**
 * 每个线程循环 1w 次，累加变量 count 的值
 * ，count 默认值为 0，注意线程安全问题。
 */
public class Demo3 {
    public static int count=0;
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(()->{
            for (int i = 0; i <100000 ; i++) {
                count++;
            }
        });
        thread.start();
        Thread.sleep(1000);
        thread.join();
        for (int i = 0; i <100000 ; i++) {
            count++;
        }
        Thread.sleep(1000);
        System.out.println("count = "+count);

    }



}
